import Sprite from '../base/sprite'
import { getCloudUrl } from '../../utils'
import { SCORE_COLOR } from '../../constant/index'
import { screenHeight, screenWidth } from '../../constant/index'


const BG_IMG_SRC = getCloudUrl('images/jfbx.png')

/**
 * 计分牌
 */
export default class Scoreboard extends Sprite {
  constructor(ctx) {
    super(BG_IMG_SRC, 80, 48)
    this.render(ctx)
    this.x = 10
    this.y = screenHeight / 2 - 68
  }
  setSrc (src) {
    this.img.src = src
  }
  renderGameScore(ctx, score) {
    ctx.fillStyle = SCORE_COLOR
    ctx.font = '20px Arial'

    ctx.fillText(
      score,
      this.x + 36,
      this.y + 36
    )
  }
  render(ctx) {
    ctx.drawImage(
      this.img,
      this.x,
      this.y,
      this.width,
      this.height
    )
  }
}
